﻿@{
    ViewBag.Title = "UserAction";
    Layout = "~/Views/Shared/_LayoutChild.cshtml";
}
@section head
{
    @if (false) {<script src="~/Scripts/jquery-1.6.4-vsdoc.js" type="text/javascript"></script>}
    <script type="text/javascript">
        $(document).ready(function () {
            $("select").width(200);
            loadUserActions();
            $("#MenuID").change(function () {
                getUserActionTreeObj().reAsyncChildNodes(null, "refresh");
            })
        });

        function zTreeUserActionCheck(event, treeId, treeNode) {
            var nodes = getUserActionTreeObj().getCheckedNodes(true);
            var _actionIds = '';
            for (var i = 0; i < nodes.length; i++) {
                _actionIds += nodes[i].ActionID + ",";
            }
            if (_actionIds.length > 0)
                _actionIds = _actionIds.substring(0, _actionIds.length - 1);
            $.post('@Url.Content("~/SystemManage/User/SaveUserActions")', { userId: '@ViewBag.UserID', menuId: $("#MenuID").val(), actionIds: _actionIds },
                function (d) {
                    if (d.Success) {
                        parent.asyncbox.tips('操作成功!', 'success', 1000);
                    }
                    else {
                        parent.asyncbox.tips('操作失败!', 'error', 1000);
                    }
                });
        }
    </script>
}
<div class="ui-layout-center">
    <table style="margin-left: 10px; margin-top: 10px;">
        <tr>
            <td>
                菜单:
            </td>
            <td>
                @Html.DropDownList("MenuID", (IEnumerable<SelectListItem>)ViewBag.Menus)
            </td>
        </tr>
        <tr>
            <td colspan="2">
                @Html.Partial("_UserActionTree")
            </td>
        </tr>
    </table>
</div>
